package com.scau.yangsuiyu.estore.dababases.entity;

import javax.persistence.*;
import java.util.Objects;

/**
 * @author suiyu_yang
 * @description
 * @date 2019-06-13 17:57
 * @email suiyu_yang@163.com
 */
@Entity
@Table(name = "order_detail", schema = "db_shop", catalog = "")
@IdClass(OrderDetailPK.class)
public class OrderDetail {
    private int orderId;
    private int itemId;

    @Id
    @Column(name = "order_id")
    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    @Id
    @Column(name = "item_id")
    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        OrderDetail that = (OrderDetail) o;
        return orderId == that.orderId &&
                itemId == that.itemId;
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderId, itemId);
    }
}
